/**
 * 
 */
package com.swfee.qinben.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.swfee.qinben.model.AppLog;

/**
 * @author ddr
 * 
 */
public class AppLogService extends DbBaseService<AppLog> {
	public AppLogService(Context ctx) {
		super(ctx);
	}

	public final static String[] CLOUMNS = { "id", "open_date" };
	public final static String TABLE_NAME = "t_app_log";

	
	
	
	public void logFirst(){
		AppLog ap = new AppLog();
		ap.setOpenDate(new Date());
		ap.setId("1");
		insert(ap);
		return ;
	}
	
	public boolean  firstUse() {
		List<?> l = getAll();
		return l==null || l.isEmpty();
	}

	public AppLog cursorToModel(Cursor cu) {
		AppLog ps = new AppLog();
		int i = 0;
		ps.setId(cu.getString(i++));
		ps.setOpenDate(new Date(cu.getLong(i++)));
		return ps;
	}

	public List<AppLog> cursorToModels(Cursor cu) {
		List<AppLog> list = new ArrayList<AppLog>();
		while (cu.moveToNext()) {
			list.add(cursorToModel(cu));
		}
		return list;
	}

	@Override
	public String[] getClounms() {
		return CLOUMNS;
	}

	@Override
	public String getTableName() {
		return TABLE_NAME;
	}

}
